package com.itheima.集合;

import java.util.ArrayList;
import java.util.Scanner;

public class TestStudent {
    public static ArrayList<Student> shaixuan(ArrayList<Student> list) {
        ArrayList<Student> list2 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++){
            int temp = Integer.parseInt(list.get(i).getId());
            if(temp < 18) {
                list2.add(list.get(i));
            }
        }
        return list2;
    }
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<String> list1 = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            String s = sc.nextLine();
            String[] arr = s.split("，");
            list1.add(arr[0]);
            list1.add(arr[1]);
        }


        Student st1 = new Student(list1.get(0),list1.get(1));
        Student st2 = new Student(list1.get(2),list1.get(3));
        Student st3 = new Student(list1.get(4),list1.get(5));

        //数组
        Student[] arr = new Student[3];
        arr[0] = st1;
        arr[1] = st2;
        arr[2] = st3;

        for (int i = 0; i < arr.length; i++) {
            Student temp = arr[i];
            System.out.println(temp.getId() + "......" + temp.getName());
        }

        //集合
        ArrayList<Student> list = new ArrayList<>();
        list.add(st1);
        list.add(st2);
        list.add(st3);

        for (int i = 0; i < list.size(); i++) {
            Student temp = list.get(i);
            System.out.println(temp.getId() + "......" + temp.getName());
        }

        //筛选
        ArrayList<Student> list3 = shaixuan(list);
        for (int i = 0; i < list3.size(); i++) {
            Student temp = list3.get(i);
            System.out.println("筛选后：");
            System.out.println(temp.getId() + "......" + temp.getName());
        }

    }
}
